package lar.system.opengl;

import javax.microedition.khronos.opengles.GL11;

import lar.system.engine.MainProgram;
import lar.system.engine.TouchListener;

import android.util.Log;
import android.view.MotionEvent;

public class GLButton implements Drawable
{

	private GLImage buttonImage;
	private TouchListener listener;

	
	public GLButton(int resourceId, float[] glPos, float[] glDim, TouchListener tL)
	{
		buttonImage = new GLImage(resourceId, glPos, glDim);
		MainProgram.glSurfaceView.addTouchListener(tL, this);
		listener = tL;
	}
	
	public TouchListener getTouchListener()
	{
		return listener;
	}
	
	public void setTouchListener(TouchListener obj)
	{
		if(obj == null) return;
		if(listener != null) MainProgram.glSurfaceView.removeTouchListener(listener);
		MainProgram.glSurfaceView.addTouchListener(obj, this);
		listener = obj;
	}
	
	public void removeTouchListener()
	{
		if(listener != null) MainProgram.glSurfaceView.removeTouchListener(listener);
	}
	
	public GLImage getImage()
	{
		return buttonImage;
	}
	
	public void Draw(GL11 gl) 
	{
		if(buttonImage != null) buttonImage.Draw(gl);
	}

	public boolean CheckBounds(float x, float y) 
	{
		return buttonImage.CheckBounds(x, y);
	}


	
}
